package org.example;

import java.io.*;

public class Test {
    public static void main(String[] args) throws IOException {
        FileWriter fileWriter = new FileWriter("D:/桌面/tmp1.txt");
        try (BufferedReader br = new BufferedReader(new FileReader("D:/桌面/result1.txt"))) {
            String line;
            br.readLine();
            fileWriter.append("x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,x8,y8,x9,y9,x10,y10\n");
            while ((line = br.readLine()) != null) {
                line = line.substring(line.lastIndexOf(':') + 1);
                String[] tmp = line.split(",");
                for (int i = 1; i < tmp.length; i += 2) {
                    fileWriter.append(tmp[i] + ",");
                    System.out.print(tmp[i] + ",");
                }
                for (int i = 2; i < tmp.length; i += 2) {
                    fileWriter.append(tmp[i] + ",");
                    System.out.print(tmp[i] + ",");
                }
                fileWriter.append("\n");
                System.out.println();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main1(String[] args) {
        try {
            BufferedReader bufferedReader = new BufferedReader(new FileReader("D:/桌面/附件1.txt"));
            FileWriter fileWriter = new FileWriter("D:/桌面/result1.txt");
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                line = line.replaceAll("\\(","");
                line = line.replaceAll("\\)","");
                System.out.println(line);
                fileWriter.append(line);
                fileWriter.append("\n");
            }

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
